<?php if (!defined('THINK_PATH')) exit(); /*a:5:{s:74:"E:\workplace\project\Sunwm\web/../application/admin\view\service\edit.html";i:1512717449;s:75:"E:\workplace\project\Sunwm\web/../application/admin\view\public\header.html";i:1503189484;s:75:"E:\workplace\project\Sunwm\web/../application/admin\view\public\seller.html";i:1508382600;s:77:"E:\workplace\project\Sunwm\web/../application/admin\view\public\category.html";i:1508382800;s:75:"E:\workplace\project\Sunwm\web/../application/admin\view\public\footer.html";i:1512624954;}*/ ?>
﻿<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title><?php echo config('sitename'); ?>-<?php echo lang('label')['Login_title']; ?></title>
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/public/css/pintuer.css" />
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/admin/css/admin.css" />
		<script type="text/javascript" src="__ROOT__/static/public/js/jquery.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/js/pintuer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/admin/js/admin.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/layer/layer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laydate/laydate.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laytpl/laytpl.js"></script>
	</head>

	<body>
	<style>
		html { overflow-x:hidden; }
	</style>
<link rel="stylesheet" type="text/css" href="__ROOT__/static/public/umeditor/themes/default/css/umeditor.css" />
<script type="text/javascript" src="__ROOT__/static/public/umeditor/third-party/template.min.js"></script>
<script type="text/javascript" src="__ROOT__/static/public/umeditor/umeditor.config.js"></script>
<script type="text/javascript" src="__ROOT__/static/public/umeditor/umeditor.min.js"></script>
	<form method="post" class="form-x" action="<?php if($data['id']): ?>?id=<?php echo $data['id']; endif; ?>">
	<div class="panel admin-panel">
		<div class="panel-head"><strong><?php echo lang('currency')['edit']; ?></strong></div>
		<br/>
		<script>
            var cate_id="<?php echo $data['cate_id']; ?>";
            var uid="<?php echo $data['uid']; ?>";
            if(!uid){
                uid="<?php echo input('get.uid'); ?>";
			}
            function select_uid() {
                start_service_category();
            }
		</script>
		<div class="form-group">
			<div class="label">
				<label><?php echo lang('label')['seller']; ?></label>
			</div>
			<div class="field">
				<select id="uid" name="uid" class="input input-auto">
	<option value="0">请选择</option>
</select>
<script id="uid_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
		<option {{# if(d.data[i].id==uid){}}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script>
	var func = false;
	$('select').click(function(){
		func = true;
	});
	function start_seller(){
        $.getJSON('__URL__/get_seller', {}, function(res){
            if(res.data.length > 0 ){
                var tpl = $("#uid_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#uid").html('<option value="0">请选择</option>'+render);
                });
            }
        });
	}
    start_seller();
	$('[name=uid]').change(function(){
		uid = $(this).val();
		if(func == true){
			select_uid();
		}
	});
</script>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="title"><?php echo lang('label')['category']; ?></label>
			</div>
			<div class="field">
				<select id="cate_id" name="cate_id" class="input input-auto">
	<option value="0">请选择</option>
</select>
<script id="cateid_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
		<option {{# if(d.data[i].id==cate_id){}}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].title }}</option>
	{{# } }}
</script>
<script>
	var func = false;
	$('select').click(function(){
		func = true;
	});
	function start_service_category() {
        $.getJSON('__ROOT__/admin/<?php echo \think\Request::instance()->controller(); ?>/ajax_get?uid=' + uid, {}, function (res) {
            if (res.data.length > 0) {
                var tpl = $("#cateid_list_tpl").html();
                laytpl(tpl).render(res, function (render) {
                    $("#cate_id").html('<option value="0">请选择</option>' + render);
                });
            }
        });
    }
    if(uid != ''){
        start_service_category();
    }
	/*$('[name=gid]').change(function(){
		gid = $(this).val();
		if(selectc == true && gid != 0){
			$.getJSON('__ROOT__/admin/<?php echo \think\Request::instance()->controller(); ?>/ajax_get?id='+gid, {}, function(res){
				if(res.data.length > 0 ){
					var tpl = $("#cateid_list_tpl").html();
					laytpl(tpl).render(res, function(render){
						$("#cateid").html(render);
					});
					if(selectc == true){
						$('[name=cate_id]').removeClass('hidden');
						$('[name=cate_id]').change();
					}
				}else{
					$('[name=cateid]').addClass('hidden');
				}
			});
		}
		if(func == true){
			select_g();
		}
	});*/
	$('[name=cate_id]').change(function(){
		cate_id = $(this).val();
		if(func == true){
			select_cate();
		}
	});
</script>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="title"><?php echo lang('label')['title']; ?></label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="title" name="title" value="<?php echo $data['title']; ?>" size="80" placeholder="<?php echo lang('label')['title']; ?>" data-validate="required:<?php echo lang('currency')['required']; ?>" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="price"><?php echo lang('label')['price']; ?></label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="price" name="price" value="<?php echo $data['price']; ?>" size="80" placeholder="<?php echo lang('label')['price']; ?>" data-validate="required:<?php echo lang('currency')['required']; ?>" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="price"><?php echo lang('label')['box_charge']; ?></label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="box_charge" name="box_charge" value="<?php echo $data['box_charge']; ?>" size="80" placeholder="<?php echo lang('label')['box_charge']; ?>" data-validate="required:<?php echo lang('currency')['required']; ?>" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="spec"><?php echo lang('label')['spec']; ?></label>
			</div>
			<div class="field">
			<?php if($speclist): if(is_array($speclist) || $speclist instanceof \think\Collection || $speclist instanceof \think\Paginator): $i = 0; $__LIST__ = $speclist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$spec): $mod = ($i % 2 );++$i;if($spec['title']): ?>
			<div style="padding: 5px 0px;">
				<input type="hidden" name="spec[<?php echo $i-1; ?>][id]" size="30" value="<?php echo $spec['id']; ?>" /> 
				<input type="text" class="input input-auto" name="spec[<?php echo $i-1; ?>][title]" size="30" value="<?php echo $spec['title']; ?>" placeholder="<?php echo lang('label')['spec']; ?>"  /> 
				<input type="text" class="input input-auto" name="spec[<?php echo $i-1; ?>][price]" size="10" value="<?php echo $spec['price']; ?>" placeholder="<?php echo lang('label')['price']; ?>" />
				<?php if($i == 1): ?>
				<button type="button" class="button addspec">+</button>
				<?php else: ?>
				<button type="button" class="button delspec">-</button>
				<?php endif; ?>
			</div>
			<?php endif; endforeach; endif; else: echo "" ;endif; else: ?>
			<div style="padding: 5px 0px;">
				<input type="hidden" name="spec[0][id]" size="30" /> 
				<input type="text" class="input input-auto" name="spec[0][title]" size="30" placeholder="<?php echo lang('label')['spec']; ?>"  /> 
				<input type="text" class="input input-auto" name="spec[0][price]" size="10" placeholder="<?php echo lang('label')['price']; ?>" />
				<button type="button" class="button addspec">+</button>
			</div>
			<?php endif; ?>
			</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image1"><?php echo lang('label')['image']; ?>1</label>
			</div>
			<div class="field">
				<input type="text" readonly class="input input-auto" id="image1" name="image1" value="<?php echo $data['image1']; ?>" size="65" placeholder="<?php echo lang('label')['image']; ?>" data-validate="required:<?php echo lang('currency')['required']; ?>" />
				<span class="addbtn"><button type="button" data-id="image1" class="button upload"><?php echo lang('form')['file']; ?></button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image2"><?php echo lang('label')['image']; ?>2</label>
			</div>
			<div class="field">
				<input type="text" readonly onclick="$(this).val('')" class="input input-auto" id="image2" name="image2" value="<?php echo $data['image2']; ?>" size="65" placeholder="<?php echo lang('label')['image']; ?>" />
				<span class="addbtn"><button type="button" data-id="image2" class="button upload"><?php echo lang('form')['file']; ?></button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image3"><?php echo lang('label')['image']; ?>3</label>
			</div>
			<div class="field">
				<input type="text" readonly onclick="$(this).val('')" class="input input-auto" id="image3" name="image3" value="<?php echo $data['image3']; ?>" size="65" placeholder="<?php echo lang('label')['image']; ?>" />
				<span class="addbtn"><button type="button" data-id="image3" class="button upload"><?php echo lang('form')['file']; ?></button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image4"><?php echo lang('label')['image']; ?>4</label>
			</div>
			<div class="field">
				<input type="text" readonly onclick="$(this).val('')" class="input input-auto" id="image4" name="image4" value="<?php echo $data['image4']; ?>" size="65" placeholder="<?php echo lang('label')['image']; ?>" />
				<span class="addbtn"><button type="button" data-id="image4" class="button upload"><?php echo lang('form')['file']; ?></button></span>
			</div>
		</div>
		</div>
		<!--<div class="form-group">
			<div class="label">
				<label>商品类型</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button <?php if($data['type'] == "0" || !$data['type']): ?>active<?php endif; ?>"><input name="type" value="0" <?php if($data['type'] == "0" || !$data['type']): ?>checked="checked"<?php endif; ?> type="radio">商品外卖</label>
					<label class="button <?php if($data['type'] == "1"): ?>active<?php endif; ?>"><input name="type" value="1" <?php if($data['type'] == "1"): ?>checked="checked"<?php endif; ?> type="radio">上门服务</label>
					<label class="button <?php if($data['type'] == "2"): ?>active<?php endif; ?>"><input name="type" value="2" <?php if($data['type'] == "2"): ?>checked="checked"<?php endif; ?> type="radio">到店使用</label>
				</div>
			</div>
		</div>-->
		<div class="form-group">
			<div class="label">
				<label><?php echo lang('label')['status']; ?></label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button <?php if(!$data['status']): ?>active<?php endif; ?>"><input name="status" value="0" <?php if(!$data['status']): ?>checked="checked"<?php endif; ?> type="radio"> <span class="icon icon-times"></span>下架</label>
					<label class="button <?php if($data['status'] == "1"): ?>active<?php endif; ?>"><input name="status" value="1" <?php if($data['status'] == "1"): ?>checked="checked"<?php endif; ?> type="radio"><span class="icon icon-check"></span> 上架</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>必选</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button <?php if($data['required'] == "1"): ?>active<?php endif; ?>"><input name="required" value="1" <?php if($data['required'] == "1"): ?>checked="checked"<?php endif; ?> type="radio"><span class="icon icon-check"></span> 是</label>
					<label class="button <?php if(!$data['required']): ?>active<?php endif; ?>"><input name="required" value="0" <?php if(!$data['required']): ?>checked="checked"<?php endif; ?> type="radio"> <span class="icon icon-times"></span> 否</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>是否店内</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button <?php if($data['type'] == "1"): ?>active<?php endif; ?>"><input name="type" value="1" <?php if($data['type'] == "1"): ?>checked="checked"<?php endif; ?> type="radio"><span class="icon icon-check"></span> 是</label>
					<label class="button <?php if(!$data['type']): ?>active<?php endif; ?>"><input name="type" value="0" <?php if(!$data['type']): ?>checked="checked"<?php endif; ?> type="radio"> <span class="icon icon-times"></span> 否</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>活动</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button <?php if(!$data['flag']): ?>active<?php endif; ?>"><input name="flag" value="0" <?php if(!$data['flag']): ?>checked="checked"<?php endif; ?> type="radio"> <span class="icon icon-check"></span> 无</label>
					<label class="button <?php if($data['flag'] == "1"): ?>active<?php endif; ?>"><input name="flag" value="1" <?php if($data['flag'] == "1"): ?>checked="checked"<?php endif; ?> type="radio"><span class="icon icon-check"></span> 团购</label>
					<label class="button <?php if($data['flag'] == "2"): ?>active<?php endif; ?>"><input name="flag" value="2" <?php if($data['flag'] == "2"): ?>checked="checked"<?php endif; ?> type="radio"><span class="icon icon-check"></span> 秒杀</label>
					<label class="button <?php if($data['flag'] == "3"): ?>active<?php endif; ?>"><input name="flag" value="3" <?php if($data['flag'] == "3"): ?>checked="checked"<?php endif; ?> type="radio"><span class="icon icon-check"></span> 限时购</label>
				</div>
			</div>
		</div>
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/admin/css/daterangepicker.css" />
		<script type="text/javascript" src="__ROOT__/static/public/js/moment.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/js/daterangepicker.js"></script>
		<style>
			.daterangepicker{
				display:none;
				border: 1px solid #08C;
			}
		</style>
		<div class="form-group">
			<div class="label">
				<label>时间</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
						<button type="button" class="button button-default pull-right" id="daterange-btn">
							<span>
							<?php if($data['start_time']): ?>
							<?php echo date('Y-m-d H:i',$data['start_time']); ?> 至 <?php echo date('Y-m-d H:i',$data['end_time']); else: ?>
							  <i class="icon-calendar"></i> 日期选择
							<?php endif; ?>
							</span>
							<i class="icon-caret-down"></i>
						</button>
						<input type="hidden" id="start_time" name="start_time" value="<?php echo $data['start_time']; ?>"/>
						<input type="hidden" id="end_time" name="end_time" value="<?php echo $data['end_time']; ?>"/>
						<script>
							var start_time="<?php echo $data['start_time']; ?>",end_time="<?php echo $data['end_time']; ?>";
							$('#daterange-btn').daterangepicker({
									opens: "right",
									drops:"up",
									ranges: {
										'今天': [moment(), moment()],
										'本周': [moment().startOf('week'), moment().endOf('week')],
										'本月': [moment().startOf('month'), moment().endOf('month')],
										'今年': [moment().startOf('year'), moment().endOf('year')]
									},
									timePicker:true,
									startDate: moment(),
									endDate: moment().endOf('month')
								},
								function(start, end) {
									start_time = start.format('YYYY-M-DD h:mm A');
									end_time = end.format('YYYY-M-DD h:mm A');
									$('#daterange-btn span').html(start_time + ' 至 ' + end_time);
									$('#start_time').val(start_time);
									$('#end_time').val(end_time);
								}
							);
						</script>
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>打</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<input type="number" min="0.0" step="0.1" value="<?php echo $data['discount']; ?>" name="discount" max="10" class="input input-auto" style="width: 80px"> 折
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>介绍</label>
			</div>
			<div class="field">
				<textarea name="service" class="input input-auto" rows="5" cols="80" style="min-height: 165px" placeholder="商品介绍"><?php echo $data['service']; ?></textarea>
			</div>
		</div>
		<div id="refuse" class="form-group<?php if($data['status'] != '4'): ?> hidden <?php endif; ?>">
			<div class="label">
				<label for="refuse"><?php echo lang('label')['refuse']; ?></label>
			</div>
			<div class="field">
				<textarea name="refuse" class="input input-auto" rows="5" cols="80" placeholder="<?php echo lang('label')['refuse']; ?>" ><?php echo $data['refuse']; ?></textarea>
			</div>
		</div>
		<div class="form-button">
			<button class="button bg-main" type="submit"><?php echo lang('form')['submit']; ?></button>
		</div>
		<br/>
		</div>
	</form>
		<script>
		$("[name='status']").click(function(){
			var status = $("[name='status']:checked").val();
			if(status=='4'){
				$("#refuse").removeClass('hidden');
			}else{
				$("#refuse").addClass('hidden');
			}
		});
		$(".addspec").click(function(){
			var num = $(this).parent().parent().find("div").length;
			var html = '<div style="padding: 5px 0px;"><input type="text" class="input input-auto" name="spec['+num+'][title]" size="30" placeholder="<?php echo lang('label')['spec']; ?>"  /> <input type="text" class="input input-auto" name="spec['+num+'][price]" size="10" placeholder="<?php echo lang('label')['price']; ?>" /> <button type="button" class="button delspec">-</button></div>';
			$(this).parent().parent().append(html);
		});
		$(document).on("click",".delspec",function(){
			$(this).parent().remove();
		})
		var um = UM.getEditor('myEditor');
	</script>
<p class="text-center text-gray" style="margin-top:10px;"><a class="text-gray" target="_blank" href="http://www.wm0530.com">完美外卖系统 Power by 网络工厂</a></p>
</body>
<script>
$('.upload').on('click',function (){
		var id = $(this).attr('data-id');
		 upload(id);
	}
);
function upload(id){
	layer.open({
		type:2,
		title:false,
		area: ['70%', '90%'],
		offset: '5%',
		content: "<?php echo url('/admin/material'); ?>?id="+id
	});
}
</script>
</html>